IProducerConsumerCollection(T).TryTake Method

Task Parallel System.Threading

Attempts to remove and return an object from the IProducerConsumerCollection<(Of <(T>)>).

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Private Function TryTake ( _
	<OutAttribute> ByRef item As T _
) As Boolean Implements IProducerConsumerCollection(Of T).TryTake
C#
bool IProducerConsumerCollection<T>.TryTake(
	out T item
)

Parameters

item
Type: T %
When this method returns, if the operation was successful, item contains the object removed. If no object was available to be removed, the value is unspecified.

Return Value

true if an element was removed and returned succesfully; otherwise, false.

Implements

IProducerConsumerCollection<(Of <(T>)>)..::.TryTake(T%)

Remarks

For ConcurrentQueue<(Of <(T>)>), this operation will attempt to remove the object from the beginning of the ConcurrentQueue<(Of <(T>)>).

See Also